﻿<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/MyMaster.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div style="border-bottom: solid silver; margin:10px 25px 0px 25px;">
        <label style="font-size:20px; margin-left:5px;"><b>Tin tức mới nhất<br />
        <br />

        </b></label>
        
        <asp:SqlDataSource ID="loaisp" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [Loaisanpham]"></asp:SqlDataSource>
        &nbsp;<asp:SqlDataSource ID="sql_tintuc" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT TOP 6 * FROM tintuc order by ngaydang desc">
        </asp:SqlDataSource>
        <asp:DataList ID="datalistTinTuc" runat="server" DataKeyField="id_row" 
            DataSourceID="sql_tintuc" RepeatColumns="4" HorizontalAlign="Justify">
            <ItemTemplate>
                <table width="180px">
                    <tr>
                        <td style="text-align:center; height:150px;">
                            <asp:Image ID="imgHinhAnh" runat="server" Height="120px" Width="110px" 
                                ImageUrl='<%# "~/images/TinTuc/" + Eval("id_row") + "/hinhchude.jpg" %>' />
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align:center; height:40px" valign="top">
                            <asp:HyperLink ID="hyp_tintuc" runat="server" ForeColor="Black" 
                                NavigateUrl='<%# "~/TinTucChiTiet.aspx?id_row=" + Eval("id_row")%>' Text='<%# Eval("tieude") %>' />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>
    </div>
    <div style="margin:10px 25px 0px 25px;">
                    <asp:Repeater ID="Repeater3" runat="server" DataSourceID="loaisp">
        <ItemTemplate>
        <p><%#Eval("tenloai") %></p>
                <asp:Repeater ID="Repeater4" runat="server" DataSourceID="dssp">
         <ItemTemplate>
                <table  width="180px" style="text-align:center;">
                    <tr>
                        <td style="vertical-align:middle; height:200px; width:200px;">
                            <asp:Image ID="imgHinhAnh" runat="server" Height="200px" Width="200px" 
                                ImageUrl='<%# "~/images/SanPham/" + Eval("id_row") + "/hinhchude.jpg" %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:HyperLink ID="hyp_tensp" runat="server" ForeColor="DarkBlue" Font-Bold="true" Text='<%# Eval("tensp") %>'
                                        NavigateUrl='<%# "~/LaptopChiTiet.aspx?id_row=" + Eval("id_row")%>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblGiaBan" runat="server" Text='<%# "Giá bán: <b>" + Eval("dongia","{0:###,###}") + " VNĐ</b>" %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblTinhTrang" runat="server" Font-Size="10" Font-Italic="true" Text='<%# Eval("tinhtrang") %>' />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:Repeater>
            <asp:Label ID="lbid" runat="server" Text='<%#Eval("id_row") %>' Visible="false"></asp:Label>
        <asp:SqlDataSource ID="dssp" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [SanPham] WHERE ([id_loaisp] = @id_loaisp)">
            <SelectParameters>
                <asp:ControlParameter ControlID="lbid" Name="id_loaisp" 
                    PropertyName="Text" Type="Decimal" />
            </SelectParameters>
        </asp:SqlDataSource>
        </ItemTemplate>
        </asp:Repeater>
</div>
</asp:Content>
